package com.kehongborui.empmanagesys.util.tag;

import com.kehongborui.empmanagesys.controller.ActionServlet;

import javax.servlet.Servlet;
import javax.servlet.jsp.JspContext;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.BodyTagSupport;
import javax.servlet.jsp.tagext.SimpleTag;
import javax.servlet.jsp.tagext.SimpleTagSupport;
import java.io.IOException;
import java.sql.Date;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;

/**
 * @author zhang peng yang ming
 * @CopyRight (C) http://www.csdn.com
 * @brief
 * @email 122162005@qq.com
 * @date 2018-07-20
 */
public class Timestamp2FormatTag extends SimpleTagSupport {
    private String date;
    private String format;

    @Override
    public void doTag() throws JspException, IOException {
        PageContext jspContext = (PageContext) getJspContext();
        JspWriter out = jspContext.getOut();
        out.write(new SimpleDateFormat(format).format(date));
    }

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public String getFormat() {
        return format;
    }

    public void setFormat(String format) {
        this.format = format;
    }
}
